
//对象处理工具
let _object = {

  //是否存在某键
  _isset: function (key, ob) {

    return typeof ob == "object" ? ob.hasOwnProperty(key) : false;
  },

  //获取对象键
  _keys: function (ob) {

    return ob == null ? [] : Object.keys(ob);
  },

  //获取对象元素长度
  _length: function (ob) {

    return ob == null ? 0 : Object.keys(ob).length;
  },

  //合并对象
  _merge: function (ob, source) {

    if (this._length(ob) > 0)
    {
      for (let key in ob)
      {
        source[key] = ob[key];
      }
    }
  },

  //克隆
  _clone: function (ob) {
    let o = {};
    if (this._length(ob) > 0)
    {
      for (let key in ob)
      {
        o[key] = ob[key];
      }
    }
    return o;
  },

  //覆盖
  _cover: function (ob, source) {
    if (this._length(ob) > 0 && this._length(source) > 0)
    {
      for (let key in source)
      {
        if (ob.hasOwnProperty(key))
        {
          source[key] = ob[key];
        }
      }
    }
  },

  //重置对象
  _reset: function (ob, source) {
    source = ob;
  },

  //转换数组
  _to_array: function (ob) {

    let array = [];
    if (this._length(ob) > 0)
    {
      for (let key in ob)
      {
        array.push(ob[key]);
      }
    }
    return array;
  }
};

//导出
export default _object;